﻿namespace SmartSoft.Controls.ChildGridControls
{
    using SmartSoft;
    using SmartSoft.Controls;
    using System;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class SearchLotNumberCell : DataGridViewTextBoxCell
    {
        private bool ib_CheckMovable = true;
        private bool ib_EmptyIsValid;
        private bool ib_FoundIsValid = true;
        private DateTime id_InvoiceDate;
        private AppInstance.TextControlLength ie_UserTextLength = AppInstance.TextControlLength.ItemCode;
        private AppInstance.TextControlTrimMode ie_UserTrimMode = AppInstance.TextControlTrimMode.Right;
        private object ii_InvoicePosted = 1;
        private int ii_LocalWorkArea;
        private string is_DestinationFields = "";
        private string is_DetailKey;
        private string is_FirstFilter = "";
        private object is_InventoryCode;
        private object is_InventoryInputCode;
        private object is_LocalItemCode;
        private string is_MasterKey;
        private object is_RackNumber;
        private string is_SourceFields = "";
        private string is_TableName = "";
        private Color oDisabledForeColor = Color.Blue;
        private DataTable oLocalDetailTable;

        public override object Clone()
        {
            SearchLotNumberCell cell = base.Clone() as SearchLotNumberCell;
            if (cell != null)
            {
                cell.DisabledForeColor = this.DisabledForeColor;
                cell.EmptyIsValid = this.EmptyIsValid;
                cell.FoundIsValid = this.FoundIsValid;
                cell.TableName = this.TableName;
                cell.FirstFilter = this.FirstFilter;
                cell.SourceFields = this.SourceFields;
                cell.DestinationFields = this.DestinationFields;
                cell.UserTrimMode = this.UserTrimMode;
                cell.UserTextLength = this.UserTextLength;
                cell.CheckMovable = this.CheckMovable;
                cell.InvoicePosted = this.InvoicePosted;
                cell.InvoiceDate = this.InvoiceDate;
                cell.MasterKey = this.MasterKey;
                cell.DetailKey = this.DetailKey;
                cell.InventoryCode = this.InventoryCode;
                cell.InventoryInputCode = this.InventoryInputCode;
                cell.RackNumber = this.RackNumber;
                cell.LocalItemCode = this.LocalItemCode;
                cell.LocalDetailTable = this.LocalDetailTable;
                cell.LocalWorkArea = this.LocalWorkArea;
            }
            return cell;
        }

        public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
            TextSearchLotNumber editingControl = base.DataGridView.EditingControl as TextSearchLotNumber;
            if (editingControl != null)
            {
                editingControl.BorderStyle = BorderStyle.None;
                editingControl.DisabledForeColor = this.DisabledForeColor;
                editingControl.EmptyIsValid = this.EmptyIsValid;
                editingControl.FoundIsValid = this.FoundIsValid;
                editingControl.TableName = this.TableName;
                editingControl.FirstFilter = this.FirstFilter;
                editingControl.SourceFields = this.SourceFields;
                editingControl.DestinationFields = this.DestinationFields;
                editingControl.UserTrimMode = this.UserTrimMode;
                editingControl.UserTextLength = this.UserTextLength;
                editingControl.CheckMovable = this.CheckMovable;
                editingControl.InvoicePosted = this.InvoicePosted;
                editingControl.InvoiceDate = this.InvoiceDate;
                editingControl.MasterKey = this.MasterKey;
                editingControl.DetailKey = this.DetailKey;
                editingControl.InventoryCode = this.InventoryCode;
                editingControl.InventoryInputCode = this.InventoryInputCode;
                editingControl.RackNumber = this.RackNumber;
                editingControl.LocalItemCode = this.LocalItemCode;
                editingControl.LocalDetailTable = this.LocalDetailTable;
                editingControl.LocalWorkArea = this.LocalWorkArea;
                string str = initialFormattedValue as string;
                if (str == null)
                {
                    editingControl.Text = string.Empty;
                }
                else
                {
                    editingControl.Text = str;
                }
            }
        }

        private void OnCommonChange()
        {
            if (((base.DataGridView != null) && !base.DataGridView.IsDisposed) && !base.DataGridView.Disposing)
            {
                if (base.RowIndex == -1)
                {
                    base.DataGridView.InvalidateColumn(base.ColumnIndex);
                }
                else
                {
                    base.DataGridView.UpdateCellValue(base.ColumnIndex, base.RowIndex);
                }
            }
        }

        private bool OwnsEditingSearchControl(int rowIndex)
        {
            if ((rowIndex == -1) || (base.DataGridView == null))
            {
                return false;
            }
            SearchLotNumberEditing editingControl = base.DataGridView.EditingControl as SearchLotNumberEditing;
            return ((editingControl != null) && (rowIndex == editingControl.EditingControlRowIndex));
        }

        internal void SetCheckMovable(int rowIndex, bool value)
        {
            this.ib_CheckMovable = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.CheckMovable = value;
            }
        }

        internal void SetDetailKey(int rowIndex, string value)
        {
            this.is_DetailKey = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.DetailKey = value;
            }
        }

        internal void SetEmptyIsValid(int rowIndex, bool value)
        {
            this.ib_EmptyIsValid = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.EmptyIsValid = value;
            }
        }

        internal void SetFirstFilter(int rowIndex, string value)
        {
            this.is_FirstFilter = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.FirstFilter = value;
            }
        }

        internal void SetFoundIsValid(int rowIndex, bool value)
        {
            this.ib_FoundIsValid = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.FoundIsValid = value;
            }
        }

        internal void SetInventoryCode(int rowIndex, object value)
        {
            this.is_InventoryCode = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.InventoryCode = value;
            }
        }

        internal void SetInventoryInputCode(int rowIndex, object value)
        {
            this.is_InventoryInputCode = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.InventoryInputCode = value;
            }
        }

        internal void SetInvoiceDate(int rowIndex, DateTime value)
        {
            this.id_InvoiceDate = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.InvoiceDate = value;
            }
        }

        internal void SetInvoicePosted(int rowIndex, object value)
        {
            this.ii_InvoicePosted = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.InvoicePosted = value;
            }
        }

        internal void SetLocalDetailTable(int rowIndex, DataTable value)
        {
            this.oLocalDetailTable = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.LocalDetailTable = value;
            }
        }

        internal void SetLocalItemCode(int rowIndex, object value)
        {
            this.is_LocalItemCode = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.LocalItemCode = value;
            }
        }

        internal void SetLocalWorkArea(int rowIndex, int value)
        {
            this.ii_LocalWorkArea = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.LocalWorkArea = value;
            }
        }

        internal void SetMasterKey(int rowIndex, string value)
        {
            this.is_MasterKey = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.MasterKey = value;
            }
        }

        internal void SetRackNumber(int rowIndex, object value)
        {
            this.is_RackNumber = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.RackNumber = value;
            }
        }

        internal void SetTableName(int rowIndex, string value)
        {
            this.is_TableName = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.TableName = value;
            }
        }

        internal void SetUserTextLength(int rowIndex, AppInstance.TextControlLength value)
        {
            this.ie_UserTextLength = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.UserTextLength = value;
            }
        }

        internal void SetUserTrimMode(int rowIndex, AppInstance.TextControlTrimMode value)
        {
            this.ie_UserTrimMode = value;
            if (this.OwnsEditingSearchControl(rowIndex))
            {
                this.EditingSearchControl.UserTrimMode = value;
            }
        }

        public bool CheckMovable
        {
            get
            {
                return this.ib_CheckMovable;
            }
            set
            {
                if (this.ib_CheckMovable != value)
                {
                    this.SetCheckMovable(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public string DestinationFields
        {
            get
            {
                return this.is_DestinationFields;
            }
            set
            {
                if (this.is_DestinationFields != value)
                {
                    this.is_DestinationFields = value;
                    if (this.OwnsEditingSearchControl(base.RowIndex))
                    {
                        this.EditingSearchControl.DestinationFields = value;
                    }
                }
            }
        }

        public string DetailKey
        {
            get
            {
                return this.is_DetailKey;
            }
            set
            {
                if (this.is_DetailKey != value)
                {
                    this.SetDetailKey(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public Color DisabledForeColor
        {
            get
            {
                return this.oDisabledForeColor;
            }
            set
            {
                if (this.oDisabledForeColor != value)
                {
                    this.oDisabledForeColor = value;
                    if (this.OwnsEditingSearchControl(base.RowIndex))
                    {
                        this.EditingSearchControl.DisabledForeColor = value;
                    }
                }
            }
        }

        private SearchLotNumberEditing EditingSearchControl
        {
            get
            {
                return (base.DataGridView.EditingControl as SearchLotNumberEditing);
            }
        }

        public override System.Type EditType
        {
            get
            {
                return typeof(SearchLotNumberEditing);
            }
        }

        public bool EmptyIsValid
        {
            get
            {
                return this.ib_EmptyIsValid;
            }
            set
            {
                if (this.ib_EmptyIsValid != value)
                {
                    this.SetEmptyIsValid(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public string FirstFilter
        {
            get
            {
                return this.is_FirstFilter;
            }
            set
            {
                if (this.is_FirstFilter != value)
                {
                    this.SetFirstFilter(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public bool FoundIsValid
        {
            get
            {
                return this.ib_FoundIsValid;
            }
            set
            {
                if (this.ib_FoundIsValid != value)
                {
                    this.SetFoundIsValid(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public object InventoryCode
        {
            get
            {
                return this.is_InventoryCode;
            }
            set
            {
                if (this.is_InventoryCode != value)
                {
                    this.SetInventoryCode(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public object InventoryInputCode
        {
            get
            {
                return this.is_InventoryInputCode;
            }
            set
            {
                if (this.is_InventoryInputCode != value)
                {
                    this.SetInventoryInputCode(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public DateTime InvoiceDate
        {
            get
            {
                return this.id_InvoiceDate;
            }
            set
            {
                if (this.id_InvoiceDate != value)
                {
                    this.SetInvoiceDate(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public object InvoicePosted
        {
            get
            {
                return this.ii_InvoicePosted;
            }
            set
            {
                if (this.ii_InvoicePosted != value)
                {
                    this.SetInvoicePosted(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public DataTable LocalDetailTable
        {
            get
            {
                return this.oLocalDetailTable;
            }
            set
            {
                if (this.oLocalDetailTable != value)
                {
                    this.SetLocalDetailTable(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public object LocalItemCode
        {
            get
            {
                return this.is_LocalItemCode;
            }
            set
            {
                if (this.is_LocalItemCode != value)
                {
                    this.SetLocalItemCode(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public int LocalWorkArea
        {
            get
            {
                return this.ii_LocalWorkArea;
            }
            set
            {
                if (this.ii_LocalWorkArea != value)
                {
                    this.SetLocalWorkArea(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public string MasterKey
        {
            get
            {
                return this.is_MasterKey;
            }
            set
            {
                if (this.is_MasterKey != value)
                {
                    this.SetMasterKey(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public object RackNumber
        {
            get
            {
                return this.is_RackNumber;
            }
            set
            {
                if (this.is_RackNumber != value)
                {
                    this.SetRackNumber(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public string SourceFields
        {
            get
            {
                return this.is_SourceFields;
            }
            set
            {
                if (this.is_SourceFields != value)
                {
                    this.is_SourceFields = value;
                    if (this.OwnsEditingSearchControl(base.RowIndex))
                    {
                        this.EditingSearchControl.SourceFields = value;
                    }
                }
            }
        }

        public string TableName
        {
            get
            {
                return this.is_TableName;
            }
            set
            {
                if (this.is_TableName != value)
                {
                    this.SetTableName(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public AppInstance.TextControlLength UserTextLength
        {
            get
            {
                return this.ie_UserTextLength;
            }
            set
            {
                if (this.ie_UserTextLength != value)
                {
                    this.SetUserTextLength(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public AppInstance.TextControlTrimMode UserTrimMode
        {
            get
            {
                return this.ie_UserTrimMode;
            }
            set
            {
                if (this.ie_UserTrimMode != value)
                {
                    this.SetUserTrimMode(base.RowIndex, value);
                    this.OnCommonChange();
                }
            }
        }

        public override System.Type ValueType
        {
            get
            {
                return typeof(string);
            }
        }
    }
}

